home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / GNU_C++ / LIB / NKCC-293.LZH / DOC / ENGLISH.DOC next >
Encoding:
Text File  |  1995-11-09  |  30.9 KB  |  716 lines

  1.  
  2.    NKCC - NORMALIZED KEY CODE CONVERTER
  3.    =============================================================================
  4.    Release 2.93
  5.  
  6.    Written by Harald Siegmund                           Copyright (c) 1989-1995
  7.  
  8.    NKCC is Freeware. Don't distribute modified versions of the archive to
  9.    other people. Please put a small note in your application's info dialog
  10.    if it contains NKCC (for example "Keyboard handler by Harald Siegmund").
  11.    Thanx!
  12.  
  13.    -----------------------------------------------------------------------------
  14.    Documentation and program history:
  15.  
  16.    1989:
  17.       May 14:    introducing NKCC (release 1.00)
  18.       Jun/Jul:   improvements, changes, debugging
  19.  
  20.    1990:
  21.       Jan 13:    further improvements
  22.       May 27-28: creation of file
  23.                  (complete new documentation for NKCC 2.x)
  24.       Jun 16-27: multi event assembler entry added by Gerd Knops
  25.       Jun 30:    release 1.10: return shift state flags (returned by
  26.                  nkc_multi()) compatible to NKF_... flags
  27.       Jul 09:    release 1.20: new function: nkc_kstate()
  28.       Aug 03:    release 1.30: new function: nkc_cmp()
  29.       Aug 18:    bug fixed in nkc_kstate()
  30.       Sep 15-16: release 1.40: mouse button event handler; nkc_timer()
  31.       Oct 03:    renaming NKCC II release 1.40 to NKCC release 2.40
  32.                  function overview
  33.       Oct 30:    removing chapter 6 (notes for users of NKCC 1.xx)
  34.       Nov 13:    release 2.41: NK_LEFT and NK_RIGHT exchanged
  35.       Dec 11:    release 2.50: MU_XTIMER
  36.  
  37.    1991:
  38.       Jan 11:    release 2.51: better handling of MU_XTIMER
  39.       Apr 14:    release 2.60: nkc_conv() renamed to nkc_tconv();
  40.                  new function nkc_gconv()
  41.                  rearranging and partly rewriting documentation
  42.       May 10:    release 2.61 (debugging)
  43.       May 29:    release 2.62: nkc_toupper, nkc_tolower
  44.       Jun 08:    doing some small corrections of the documentation
  45.       Aug 06:    release 2.63: quote (") is now used as synonym for
  46.                  umlaut (¨) in deadkey handling
  47.       Aug 07:    more deadkeys...
  48.       Aug 22:    release 2.70:
  49.                  deadkeys can now be enabled/disabled separately
  50.                  additional note in 3.b)
  51.                  nkc_init() now returns version #
  52.       Sep 07:    release 2.71:
  53.                  nkc_cmp() improved
  54.                  NKF_RESVD is now used:
  55.                   in key codes for internal purposes!
  56.                   in reference key code (nkc_cmp()) as flag
  57.       Nov 05:    release 2.72:
  58.                  adjustments to ASCII input feature of TOS 3.06
  59.       Nov 16:    release 2.80:
  60.                  small bug fixed in nkc_cmp()
  61.                  control key emulation (NKS_CTRL) (see chapter 1)
  62.       Dec 29:    minor changes in source documentation;
  63.                  a few new (less important) symbols were added
  64.  
  65.    1992:
  66.       Jan 03/06: introducing release 2.81:
  67.                  - nkc_init's first parameter is now an unsigned long
  68.                  - the symbolic identifiers BE_ON/OFF/TOS are redefined,
  69.                    but still have the same meaning
  70.                  - new symbols: NKI_...
  71.                  - chapters 4, 7 and 9 were adjusted respectively
  72.                    completed due to the changes in nkc_init()
  73.                  - chapters 8 and 9 got additional notes about nkc_timer()
  74.       Feb 14:    correcting documentation of nkc_exit() in chapter 4
  75.       Feb 28:    NKCOWNPB switch
  76.  
  77.    1993:
  78.       Dec 11:    release 2.90:
  79.                  - NKCC_GPB.O and SDOCSYNT.S are no longer part of the package
  80.                  - Selecting the version of NKCC for assembling (GEM or TOS) is
  81.                     done by a different symbol now: NKCGEM
  82.                  - NKCC uses its own AES/VDI parameter arrays now, execpt
  83.                    for the global array, which is passed as additional
  84.                    parameter to function nkc_init()
  85.                  - nkc_toupper and nkc_tolower are functions now rather than
  86.                    arrays
  87.                  - cosmetic changes in the documentation
  88.                  - new developer address
  89.       Dec 12:    introducing new functions nkc_n2tos() and nkc_n2gem()
  90.                  (which convert key codes in normalized format back to the
  91.                   system's format; see NKCC.TXT for details)
  92.  
  93.    1994:
  94.       Feb 01:    adding MausNet address to documentation
  95.       May 19:    release 2.91:
  96.                  - nkc_exit won't touch the system variable contern any longer
  97.                    because it may have been changed by a parallel running
  98.                    process
  99.                  - two new deadkeys were introduced:
  100.                    / + 2 = ½
  101.                    / + 4 = ¼
  102.                  - the synatx of MadMac's directives has been added to the NKCC
  103.                    source file (and NKCC.TXT)
  104.       Jun 27:    release 2.92:
  105.                  - NKCC now recognizes invalid scan codes. Their treatment is
  106.                    described in chapter 3.
  107.    1995:
  108.       Oct 31:    chapter 2 adjusted to new folder structure
  109.                  correction in chapter 3: the bit numbers of NKF_LSH and
  110.                   NKF_RSH were swapped
  111.       Nov 09:    release 2.93:
  112.                   support of the additional keys on the Macintosh keyboard
  113.                   (documented in chapter 3)
  114.  
  115.    -----------------------------------------------------------------------------
  116.    Developer contact:
  117.  
  118.    adequate systems
  119.    Gesellschaft für angemessene Systemlösungen mbH
  120.    c/o Harald Siegmund
  121.    Brauereistr. 2
  122.    D-67549 Worms
  123.    Germany
  124.  
  125.    e-mail : Harald_Siegmund@kl.maus.de (Internet address)
  126.    Mausnet: Harald Siegmund@KL
  127.    -----------------------------------------------------------------------------
  128.    The latest version of NKCC can be found in:
  129.  
  130.    Maus KL (+49-631-17901)    !! no downloads for non-paying members between !!
  131.    file NKCC.LZH              !! 7:00-9:00 and 17:00-19:00 o'clock CET       !!
  132.  
  133.    FTP server  ftp.uni-kl.de  [131.246.94.94]
  134.          file  pub/atari/programming/nkcc.lzh
  135.  
  136.    =============================================================================
  137.    Table of contents
  138.  
  139.    1. What is NKCC?
  140.    2. Files on the disk
  141.    3. The normalized key code format
  142.    4. NKCC usage
  143.    5. NKCC in TOS applications
  144.    6. NKCC in GEM applications
  145.    7. The button event handler
  146.    8. Other fine extra features
  147.    9. Symbol overview
  148.  
  149.  
  150.  
  151.  
  152.    1. What is NKCC?
  153.    =============================================================================
  154.    Did you ever try to program a complex keyboard handling? Then you sure know
  155.    some of the problems coming out of TOS along with the key codes ...
  156.  
  157.    a) pressing Alternate + any letter will only return the scan code, which is
  158.       TOS version-dependend (language)
  159.  
  160.    b) some keys get different scan codes when being pressed together with
  161.       Alternate! For example, hitting the '1' key will return a scan code
  162.       of 2 (on the German TOS) and an ASCII code of $31 (that's ok). The key
  163.       combination Alternate + '1' results in a scan code of $78 and an ASCII
  164.       code of 0!
  165.  
  166.    c) the cursor keypad (arrows, Insert, ClrHome, Help and Undo) is a whole
  167.       chaos! Some of the keys change their scan code when being pressed
  168.       together with Control. The returned ASCII code is total rubbish and
  169.       follows no rule.
  170.  
  171.    d) some different key combinations return the same key codes. In most cases,
  172.       Alternate+any key and Alternate+Shift+any key cannot be distinguished.
  173.  
  174.    The solution: the Normalized Key Code Converter
  175.  
  176.    NKCC solves all of this problems. It converts key codes received from GEMDOS
  177.    or GEM (multi event) to an own, sophisticated format, which allows to detect
  178.    all possible key combinations. In addition, NKCC offers some special
  179.    features:
  180.  
  181.    a) Deadkey handling
  182.  
  183.       People in countries which know characters with accents often have the
  184.       problem that they can't reach every character directly from the keyboard.
  185.       Or imagine a guy who wants to type a French text on a UK TOS - without
  186.       having characters like Ç or ë! This can be done if NKCC was built in his
  187.       favourite word processor. It transforms combinations of key strokes to
  188.       one character. The first one is called the deadkey: when you type it,
  189.       nothing happens - yet. After the second key stroke, NKCC decides what to
  190.       do. If matching with the first one, it merges both to one key code (for
  191.       example: ~  plus  A  will result in  Ã). If not matching, the program
  192.       will get both keys (e.g. ~  plus  X  will directly be passed through the
  193.       deadkey manager). Deadkeys known by NKCC are
  194.  
  195.       ^   +   aeiou      =  âêîôû
  196.       ~   +   nNaoAo     =  ñÑãõÃÕ
  197.       '   +   eEaiou     =  éÉáíóú
  198.       `   +   aeiouA     =  àèìòùÀ
  199.       ¨   +   aeiouyAOU  =  äëïöüÿÄÖÜ
  200.       "   +   aeiouyAOU  =  äëïöüÿÄÖÜ
  201.       °   +   aA         =  åÅ
  202.       ,   +   cC         =  çÇ
  203.       /   +   oO24       =  øØ½¼
  204.  
  205.       The quote character as synonym for umlaut is e.g. needed on the Dutch
  206.       keyboard, where neither umlaut characters nor the umlaut itself are
  207.       available.
  208.  
  209.    b) Direct input of ASCII codes
  210.  
  211.       NKCC allows the ASCII code of characters to be input directly. Just press
  212.       the Alternate key and hold it. Then type in the ASCII code on the numeric
  213.       keyboard (as decimal number). The input is finished when either the
  214.       Alternate key is relased or three digits are typed in. Values beyond 255
  215.       are truncated to 8 bit (e.g. 260 ($104) becomes 4).
  216.  
  217.    c) Control key emulation
  218.  
  219.       Usually, NKCC returns key combinations like "Control A" as ASCII code $41
  220.       (for "A") and with a set Control key flag. If the control key emulation
  221.       is enabled, "Control A" will return an ASCII code of $01. The Control key
  222.       flag will be cleared in this case.
  223.  
  224.       The Control key emulation converts ...
  225.  
  226.       Control + @       to    $00
  227.       Control + A...Z   to    $01...$1A
  228.       Control + [       to    $1B
  229.       Control + \       to    $1C
  230.       Control + ]       to    $1D
  231.       Control + ^       to    $1E
  232.       Control + _       to    $1F
  233.  
  234.       Important note:
  235.  
  236.       On several keyboards, some of the key combinations in the list above
  237.       cannot be recognized and thus not converted. For example, on the German
  238.       keyboard, the characters "@", "[", "\" and "]" can't be typed in together
  239.       with the Control key. Their ASCII codes don't appear in any of the TOS
  240.       key code tables, because they can only be reached when holding the
  241.       Alternate key. Unfortunately, TOS returns the wrong ASCII code when
  242.       Control is also held down, making it impossible to find out the original
  243.       ASCII value.
  244.  
  245.  
  246.    Every deadkey and special feature can be enabled/disabled separately.
  247.  
  248.    The best way to see how NKCC works is to start the demonstration program
  249.    (DEMO.TOS) and hack on the keyboard.
  250.  
  251.  
  252.  
  253.    2. Files on the disk
  254.    =============================================================================
  255.    The NKCC folder/disk/archive/whatever should contain the following files:
  256.  
  257.    READ_ME.TXT       the obligatory readme file...
  258.  
  259.    SOURCE\NKCC.S     source of NKCC
  260.  
  261.    HEADERS\NKCC.I    assembler header file with NKCC definitions
  262.    HEADERS\NKCC.H    C header file with NKCC definitions
  263.  
  264.    LIB\NKCC.O        NKCC as object file (DRI format)
  265.    LIB\NKCC_TOS.O    NKCC as object file without GEM part (DRI format)
  266.  
  267.    DOC\NKCC.TXT      excerpt of NKCC.S with all global definitions
  268.    DOC\ENGLISH.DOC   this documentation!
  269.    DOC\GERMAN:DOC    the documentation in German language
  270.    DOC\NEWS.TXT      information about all new features since the last release
  271.  
  272.    DEMO\DEMO.C       source of small demonstration program
  273.    DEMO\DEMO.TOS     demonstration program as executable file
  274.  
  275.  
  276.  
  277.  
  278.    3. The normalized key code format
  279.    =============================================================================
  280.    NKCC returns key codes as 16 bit integer. The low byte contains the ASCII
  281.    part of the key, the high byte is the location for some flags. Here's the
  282.    complete format:
  283.  
  284.    Bit #       Symbolic name        Contents
  285.    ------------------------------------------------------------
  286.     0... 7                          ASCII code/key code
  287.     8          NKF_RSH              right Shift key flag
  288.     9          NKF_LSH              left Shift key flag
  289.    10          NKF_CTRL             Control key flag
  290.    11          NKF_ALT              Alternate key flag
  291.    12          NKF_CAPS             current state of CapsLock key
  292.    13          NKF_NUM              numeric keypad flag
  293.    14          NKF_RESVD            reserved(!) for internal purposes
  294.    15          NKF_FUNC             function flag
  295.  
  296.    Bits 8...11 speak for themself. Bit 12 reflects the current state of the
  297.    CapsLock key. Bit 13, if set, indicates that the key is located on the
  298.    numeric keypad. Bit 14 is reserved for internal use and must be ignored.
  299.    However, it has a special meaning as parameter for the function nkc_cmp(),
  300.    described in the next chapter. Finally, the MSB of the key code (bit 15)
  301.    specifies the key type: if set, the key code stands for any function to
  302.    perform. If not set, it contains any printable character. The bit is set
  303.    when
  304.  
  305.    a) any of the following "function keys" is pressed:
  306.  
  307.       Esc, Tab, Backspace, Delete, Return,
  308.       Help, Undo, Insert, ClrHome, cursor up, cursor down, cursor left,
  309.       cursor right,
  310.       Enter,
  311.       F1, F2, F3, F4, F5, F6, F7, F8, F9, F10
  312.       Page up, Page down, End, F11, F12, F14  (Macintosh keyboard only!)
  313.  
  314.       The ASCII code for such keys is less than 32 and defined as NK_... in
  315.       the header files (e.g. NK_ESC for Escape).
  316.  
  317.    b) any key is pressed together with Alternate and/or Control
  318.  
  319.       In this case, NKCC always returns the CapsLock variant of a key (e.g.
  320.       the ASCII part of the key combination Control + A is 'A' rather than
  321.       'a').
  322.  
  323.  
  324.    The function flag was intentionally placed in bit 15 to ease its handling:
  325.  
  326.    if (keycode < 0)
  327.       perform function
  328.    else
  329.       use printable character
  330.  
  331.    The ASCII code of a printable character spans over the whole number range
  332.    of an unsigned byte: from 0 up to 255.
  333.  
  334.  
  335.    Please note that some key combinations cannot be caught by NKCC:
  336.  
  337.    a) keys which are hold back by TOS: any key of the cursor pad plus Alternate
  338.       (except Alternate + Undo); they are used for mouse controlling and to
  339.       start a screen hardcopy.
  340.  
  341.    b) characters which can only be typed in when pressing Alternate, such as
  342.       @\[{]} on the German keyboard. They are treated correctly by NKCC, but
  343.       they never appear with a set Alternate flag.
  344.  
  345.  
  346.    Characters created by the deadkey handler or the direct ASCII input are
  347.    returned as if present on the keyboard. None of the flags, except CapsLock,
  348.    can be set. Key codes created by the Control key emulation never appear with
  349.    a set Control key flag.
  350.  
  351.  
  352.    Invalid scan codes
  353.  
  354.    Older versions of NKCC produced simply garbage when they received a key
  355.    code with an invalid scan code. Since release 2.92 such key codes are
  356.    treated a defined way. They are converted to a special case of the
  357.    normalized format which cannot be achieved by using the regular keyboard.
  358.    The format is:
  359.  
  360.    function flag  = 1
  361.    alternate flag = 0
  362.    control flag   = 0
  363.    ASCII code     >= $20
  364.  
  365.    Or in other words: a printable character with set function flag, but
  366.    without Alternate and Control flags being set (this cannot occur due
  367.    to the definition of the normalized key format).
  368.  
  369.    What for, you ask? Well, the major reason for this mechanism was a
  370.    graphics tablet driver I wrote in Spring '94. The graphics tablet has
  371.    some macro buttons, and I wanted the driver to create key codes for
  372.    every macro button that was hit (which makes it very easy for
  373.    applications to receive "macro button events").
  374.  
  375.    The format of a "macro key" is:
  376.  
  377.    scan code  = $84...$ff ($ff is recommended)
  378.    ASCII code = $20...$ff (codes less than $20 are set to $20 by NKCC)
  379.  
  380.    The flags for CapsLock, LeftShift and RightShift are directly written
  381.    to the normalized key code. The Alternate and Control flags are evaluated,
  382.    too: if at least one of them is non-zero then the numeric keypad flag in
  383.    the converted key code will be set.
  384.  
  385.    Back-converting a macro key with the function nkc_n2tos() respectively
  386.    nkc_n2gem() always results in a scan code of $ff. Both Alternate and
  387.    Control will be set if the numeric keypad flag was set in the normalized
  388.    key code.
  389.  
  390.  
  391.  
  392.  
  393.    4. NKCC usage
  394.    =============================================================================
  395.    Working with NKCC is rather simple. Only a few functions have to be called.
  396.  
  397.    Before receiving the first key code, NKCC has to be initialized by an
  398.    nkc_init() call. nkc_init() gets three parameters: The first is a 32 bit
  399.    integer with some flags, defined as NKI_... in the header file NKCC.H
  400.    (respectively NKIb_.../NKIf_... in NKCC.I). The following flags exist:
  401.  
  402.    NKI_BUTHND        are both used to control the built-in handler for mouse
  403.    NKI_BHTOS         button events, described in the chapter "The button event
  404.                      handler"
  405.  
  406.    NKI_NO200HZ       if set, NKCC won't install the timer interrupt used for
  407.                      the function nkc_timer(). Note: if the button event
  408.                      handler is being activated, this flag is ignored because
  409.                      the timer is needed then for NKCC-internal purposes.
  410.  
  411.    nkc_init()'s second parameter is the handle of a virtual VDI workstation,
  412.    also needed for the button event handler. It may be zero if the handler is
  413.    not installed.
  414.  
  415.    At last the third parameter is a pointer to the applications GLOBAL array
  416.    (one of the AES parameter arrays). The pointer isn't used by NKCC_TOS.O.
  417.    When using NKCC in applications developed with Turbo C respectively Pure C
  418.    this parameter is  _GemParBlk.global  (defined in AES.H).
  419.  
  420.    The function returns a 16 bit integer with NKCC's version number as
  421.    4 digit BCD (main # in high byte, sub # in low byte).
  422.  
  423.    The most simple call of nkc_init() would be:
  424.  
  425.    nkc_init(0,0,NULL);
  426.  
  427.  
  428.    Accordingly, NKCC has to be turned off before your program is quit. This is
  429.    done by an nkc_exit() call. The function has no input parameters, but
  430.    returns a status code: if NKCC has linked itself into the system vectors,
  431.    and somebody has corrupted the XBRA vector list, it will be unable to
  432.    deinstall and returns an according error code. This is fatal! Your program
  433.    must not terminate in this case! Show a warning message and tell the user
  434.    to reboot.
  435.  
  436.  
  437.    NKCC offers several methods to receive key codes. Their main difference is
  438.    the kind of program NKCC is linked to: TOS or GEM application/accessory.
  439.    Consult the according chapters for details.
  440.  
  441.  
  442.    The special handlers for direct ASCII input, deadkey handling etc. are
  443.    controled via the function nkc_set(). The function gets a long integer with
  444.    32 flags as parameter. A set flag enables the feature, a cleared flag
  445.    disables it. Their symbolic names are:
  446.  
  447.    NKS_ALTNUM        for direct ASCII input
  448.    NKS_CTRL          for control key emulation
  449.    NKS_D_...         for deadkey management
  450.  
  451.  
  452.    When comparing two normalized key codes, no direct check should be made
  453.    (like: if (key1 == key2) ...)! Use the function nkc_cmp() instead. It uses
  454.    some specific rules which improve the flexibility of key code comparism.
  455.    The function gets two key key codes as parameters, one called "reference
  456.    key code" and the other "test key code". Some bits of the reference key code
  457.    (the first parameter) are treated a special way:
  458.  
  459.    NKF_IGNUM (same as NKF_RESVD)
  460.       if set, the numeric keypad flag doesn't matter
  461.  
  462.    NKF_CAPS (CapsLock state)
  463.       if set, the case of the ASCII code doesn't matter
  464.  
  465.    NKF_SHIFT (both Shift keys; identical to NKF_LSH | NKF_RSH)
  466.       if BOTH shift flags are set in the reference key code, the combination of
  467.       shift key flags in the test key code doesn't matter: only one shift flag
  468.       has to be set, no matter which one.
  469.  
  470.  
  471.  
  472.  
  473.    5. NKCC in TOS applications
  474.    =============================================================================
  475.    When being used in a TOS type program (without windows, AES dialogs and
  476.    mouse), the TOS-version of NKCC should be used (file NKCC_TOS.O). Some
  477.    functions for multi event and mouse handling are missing in that file,
  478.    making it some KBytes smaller.
  479.  
  480.    The functions, which have to be called, are:
  481.  
  482.    nkc_conin()
  483.       works similar to the GEMDOS functions Cconin()/Crawcin() or the BIOS
  484.       function Bconin(2). It waits until a key is pressed and returns its code
  485.       in normalized format, as 16 bit integer. The function bases on GEMDOS'
  486.       Crawcin(). If you like to use Cconin() or Bconin(), just change the
  487.       system call in the NKCC source.
  488.  
  489.    nkc_cstat()
  490.       replaces Cconis() respectively Bconstat(). It checks, if there is any key
  491.       code in the OS internal key buffer and returns an according status:
  492.       0=no key, -1=at least one key in buffer
  493.  
  494.  
  495.  
  496.  
  497.    6. NKCC in GEM applications
  498.    =============================================================================
  499.    In GEM applications or accessories, NKCC replaces the whole multi event
  500.    handler with its function nkc_multi(), which gets the same parameters as
  501.    usual C multi event bindings. The differences are:
  502.  
  503.    a) key codes are returned in normalized format
  504.  
  505.    b) the key state is returned NKCC compatible, which means: key state flags
  506.       are placed in bits 8...11 rather than bits 0...3 and can be testet using
  507.       the NKF_... symbols
  508.  
  509.  
  510.    There's no NKCC function which replaces evnt_keybd(). Please use nkc_multi()
  511.    instead - or write your own binding!
  512.  
  513.  
  514.  
  515.    Special extension for assembler programmers - by Gerd Knops
  516.    ------------------------------------------------------------
  517.  
  518.    When using the event_multi-routine, you probably have code like
  519.    this in your source-code:
  520.  
  521.    ... setting up the aes-arrays, then
  522.           bsr     aes
  523.  
  524.    with
  525.  
  526.    aes:   move.l  #aespb,d1
  527.           move    #$c8,d0
  528.           trap    #2
  529.           rts
  530.  
  531.    Simply replace 'bsr  aes' with 'bsr nkc_amulti'. Note, that you
  532.    have to use the AES-arrays from NKCC for this purpose.
  533.    See chapter 9 for a symbol overview.
  534.  
  535.  
  536.  
  537.    7. The button event handler
  538.    =============================================================================
  539.    Some years ago Atari released the long awaited TOS version 1.04. It had some
  540.    very nice new features and improvements. TOS 1.04 (or a higher version) is a
  541.    must for every ST user. Unfortunately, the guys in Sunnyvale messed up the
  542.    multi event handler in the AES, making it impossible to receive mouse button
  543.    events and timer events with short cycle times in one evnt_multi() call,
  544.    without having big problems with the double click: the multi event returns
  545.    immediately when a timer event occurs. If it was just processing a mouse
  546.    click (waiting for a possible second click), the resulting event mask is
  547.    MU_TIMER *and* MU_BUTTON! No chance to get through a double click.
  548.  
  549.    I spent hours to find a way how I could bypass this problem. Finally, I
  550.    decided to write an own mouse button event handler, and put it into NKCC.
  551.  
  552.    The NKCC button event handler is activated at initialization time. Two flags
  553.    in the longword passed to nkc_init() control whether the handler should be
  554.    installed or not:
  555.  
  556.    NKI_BUTHND              install it
  557.  
  558.    NKI_BUTHND|NKI_BHTOS    install it, if TOS version has mouse click bug (TOS
  559.                            version >= 1.04 and < 3.06)
  560.  
  561.    If the NKI_BUTHND flag is not set, the handler will not be installed (the
  562.    state of the NKI_BHTOS flag is ignored in this case).
  563.  
  564.    The second parameter of nkc_init() is the handle of a virtual VDI
  565.    workstation, which had to be opened by NKCC's caller (NKCC uses a VDI
  566.    vex_butv() call). The workstation may not be closed until nkc_exit() was
  567.    called. If the mouse button event handler has not been installed, the
  568.    handle is ignored.
  569.  
  570.    Another fine feature of the button event handler is an additional flag in
  571.    the event mask: MU_XTIMER. If this flag is set (together with MU_TIMER),
  572.    timer events will only return if no redraw-critical user action is taken
  573.    (like moving windows or sliding through the menu bar). This prevents redraw
  574.    problems, e.g. when the timer event is used to update a mouse coordinate
  575.    display.
  576.  
  577.    Note: the NKCC button event handler supports the (undocumented) negation
  578.    flag, which is passed in bit 8 of the parameter <bclicks> (maximum # of
  579.    mouse clicks to wait for). You don't know this flag? I found an article
  580.    about it in the c't magazine (I think it was issue 3/90, or maybe 4/90??) -
  581.    and I damned Atari for their bad documentation. This flag opens the way to
  582.    check BOTH mouse buttons at the same time without any problems. When set,
  583.    the return condition is inverted. Let's have a look at an example:
  584.  
  585.    mask = evnt_multi(MU_BUTTON,2,3,3,...
  586.  
  587.    This doesn't work the way we want: the return condition is "button #0
  588.    pressed AND button #1 pressed". But look at this:
  589.  
  590.    mask = evnt_multi(MU_BUTTON,0x102,3,0,...
  591.  
  592.    Now the condition is "NOT (button #0 released AND button #1 released)". Or
  593.    in other words: "button #0 pressed OR button #1 pressed". Nice, isn't it?!
  594.  
  595.  
  596.    Final note: the mouse click bug is fixed since TOS version 3.06.
  597.    Thanks to Atari Corp.!
  598.  
  599.  
  600.  
  601.  
  602.    8. Other fine extra features
  603.    =============================================================================
  604.    NKCC includes some functions primary built in for its own purposes. However,
  605.    some of this functions could also be useful for the programmers using NKCC,
  606.    so they are exported and documented. Here's a list of them:
  607.  
  608.    nkc_timer()
  609.       returns the current value of the 200 Hz system clock as unsigned longword.
  610.       The function is very fast, because it just has to copy the value from an
  611.       internal static variable to the return register.
  612.  
  613.       Note: if NKCC's timer interrupt is not installed, the function will
  614.             always return 0. See chapter 4 for details.
  615.  
  616.    nkc_kstate()
  617.       returns the current state of the Shift, Control, Alternate and CapsLock
  618.       keys in NKCC compatible format. This function is very fast, too!
  619.  
  620.    nkc_tconv()
  621.       is the heart of NKCC: the raw key code converter, which transforms a TOS
  622.       key code to the normalized format. However, it does not perform deadkey
  623.       handling, ASCII input or Control key emulation.
  624.  
  625.    nkc_gconv()
  626.       is a variant of nkc_tconv(), which gets the key code in GEM format (16
  627.       bit integer instead of 32 bit, and NO KEY STATE FLAGS!). nkc_gconv() is
  628.       surely not perfect - but that's no NKCC's fault! The key state flags are
  629.       very very important for proper conversion, and without them, several
  630.       key combinations cannot be distinguished (as meantioned in the first
  631.       chapter of this documentation). Whenever possible, use nkc_tconv()!
  632.       nkc_gconv() is more an emergency exit, which should only be used when the
  633.       key state flags are lost.
  634.  
  635.    nkc_n2tos()
  636.       converts normalized key codes back to TOS format key codes.
  637.  
  638.    nkc_n2gem()
  639.       converts normalized key codes back to GEM format key codes.
  640.  
  641.    nkc_vlink()
  642.       This function links a standard XBRA routine to a vector list. The vector
  643.       can be chosen either as absolute address (e.g. $502 for the hardcopy
  644.       vector) or as number (e.g. $02 for the bus error handler vector).
  645.  
  646.    nkc_vunlink()
  647.       The counterpart of nkc_vlink(). A function is removed from an XBRA vector
  648.       list.
  649.  
  650.    nkc_toupper()
  651.       A character is converted to upper case. In contrast to most C compiler
  652.       library functions (ctypes.h) this functions treats foreign language
  653.       characters (e.g. 'ä', 'é') correctly!
  654.  
  655.    nkc_tolower()
  656.       The counterpart of the previous function: a character is converted to
  657.       lower case.
  658.  
  659.  
  660.    For a detailed documentation of the functions consult NKCC.TXT.
  661.  
  662.  
  663.  
  664.  
  665.    9. Symbol overview
  666.    =============================================================================
  667.    Here's an overview of all symbols exported by NKCC. Functions are marked
  668.    with parentheses behind the symbol name:
  669.  
  670.       nkc_init()     initialize and configure NKCC, optional installation of an
  671.                      own mouse button event handler
  672.       nkc_exit()     exit NKCC (unlink own functions from the system etc.)
  673.       nkc_set()      enable/disable the special key handler functions
  674.                      (deadkeys, direct ASCII input, Control key emulation)
  675.       nkc_conin()    raw console character input in NKCC format (based on
  676.                      GEMDOS' Crawcin())
  677.       nkc_cstat()    sample console input status (based on GEMDOS' Cconis())
  678.    *  nkc_multi()    AES multi event binding, which returns key codes and shift
  679.                      key flags in normalized format
  680.    *  nkc_amulti()   AES multi event binding for assembler programs
  681.       nkc_tconv()    raw key code converter (TOS -> normalized format)
  682.       nkc_gconv()    additional key code converter (GEM -> normalized format)
  683.       nkc_n2tos()    additional key code converter (normalized format -> TOS)
  684.       nkc_n2gem()    additional key code converter (normalized format -> GEM)
  685.       nkc_kstate()   sample state of Shift, Control, Alternate and CapsLock
  686.                      keys in normalized format; very fast!
  687.       nkc_timer()    return current timer value of 200 Hz system clock; very
  688.                      fast! Note: if timer is disabled, the function always
  689.                      returns 0 (see chapter 4)
  690.       nkc_cmp()      compare two key codes due to standard comparism rules
  691.       nkc_vlink()    link function to XBRA vector list
  692.       nkc_vunlink()  unlink function from XBRA vector list
  693.       nkc_toupper()  lower case -> upper case conversion
  694.       nkc_tolower()  upper case -> lower case conversion
  695.  
  696.    *  nkc_contrl     AES/VDI control array
  697.    *  nkc_intin      AES/VDI integer input array
  698.    *  nkc_intout     AES/VDI integer output array
  699.    *  nkc_adrin      AES address input array
  700.    *  nkc_adrout     AES address output array
  701.                      (unfortunately the correct names - addrin and addrout -
  702.                       would create a doubly defined symbol because the
  703.                       DRI object file format supports only 8 characters per
  704.                       symbol - gosh!)
  705.    *  nkc_ptsin      VDI pointers input array
  706.    *  nkc_ptsout     VDI pointers output array
  707.                      (all arrays used for nkc_amulti())
  708.  
  709.  
  710.    *  not available in NKCC_TOS.O which is for TOS applications and excludes
  711.       the GEM part of NKCC (assembled with the NKCGEM symbol set to 0; see
  712.       header of NKCC.TXT)
  713.  
  714.    =============================================================================
  715.    End Of File
  716.